package cn.wuyi.common.context;


import java.util.HashMap;
import java.util.Map;

import cn.wuyi.common.base.Tenant;



public class Context implements Cloneable {
	
	private String tenantId;

	private Long appId;

	private Tenant tenant;
	
	 
	/**
	 * 区分运营的正式域名否
	 */
	private boolean formal = true;
	
	//展示类型 1：pc版，2：移动版
	private Integer viewType;
	
	//来源 1：前台系统，2：后台系统
	private Integer sourceApp;
	
	//是否使用viewType
	private boolean useViewType = false;
	
	 
	
	//当前访问域名
	private String currentDomain;
	
	
	private String profile;
	
	private Map<String, Object> store;

	private String unit;
	/**
	 * 当前登录用户
	 */
	private String uid;



	 
	public String getProfile() {
		return profile;
	}

	public void setProfile(String profile) {
		this.profile = profile;
	}

	public boolean isUseViewType() {
		return useViewType;
	}

	public void setUseViewType(boolean useViewType) {
		this.useViewType = useViewType;
	}

	

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public Context clone() {
		Context o = null;
		try {
			o = (Context) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return o;
	}

	 

	public Tenant getTenant() {
		if (tenant == null && tenantId != null)
			tenant = ContextUtil.getTenantById(tenantId);

		return tenant;
	}

	public void setTenant(Tenant tenant) {
		this.tenant = tenant;
	}

	public void add(String key, Object value) {
		if (store == null)
			store = new HashMap<String, Object>();

		store.put(key, value);
	}

	public Object get(String key) {
		Object result = null;

		if (store != null)
			result = store.get(key);

		return result;
	}

	public String getTenantId() {
		return tenantId;
	}

	public void setTenantId(String tenantId) {
		this.tenantId = tenantId;
	}

	public Long getAppId() {
		return appId;
	}

	public void setAppId(Long appId) {
		this.appId = appId;
	}
	
	public boolean isFormal() {
		return formal;
	}

	public void setFormal(boolean formal) {
		this.formal = formal;
	}

	public Integer getViewType() {
		return viewType;
	}

	public void setViewType(Integer viewType) {
		this.viewType = viewType;
	}

	public Integer getSourceApp() {
		return sourceApp;
	}

	public void setSourceApp(Integer sourceApp) {
		this.sourceApp = sourceApp;
	}

	public String getCurrentDomain() {
		return currentDomain;
	}

    public void setCurrentDomain(String currentDomain) {
		this.currentDomain = currentDomain;
	}

	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	 
	
}
